using System;
using Randomize.Core.Generators;

namespace Randomize.Core.Descriptors
{
    public class DoubleDescriptor : RangeGenerationDesciptor<double, IDoubleDescriptor>, IDoubleDescriptor
    {
        private int? _fracDigitsCount;

        public override IGenerator<double> CreateGenerator(Random random)
        {
            return new DoubleGenerator(random)
                   {
                       Max = this.Max,
                       Min = this.Min,
                       FractionalPartSize = _fracDigitsCount,
                       Pool = this.Pool
                   };
        }

        public IDoubleDescriptor WithFractional(int fracDigitsCount)
        {
            _fracDigitsCount = fracDigitsCount;
            return this;
        }
    }
}